package net.eldeen.stockhack.service;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.apache.log4j.Logger;

public class StockDataFetcher implements DataFetcher<String> {

  private static final Logger LOGGER = Logger.getLogger(StockDataFetcher.class);

  private WebConnect webConnect;

  public void setWebConnect(WebConnect webConnect) {
    this.webConnect = webConnect;
  }

  /* (non-Javadoc)
   * @see net.eldeen.stockhack.service.DataFetcher#fetch()
   */
  public String fetch() {
    String result = "";
    try {
      result = webConnect.fetchStocksData();
    }
    catch (ClientProtocolException e) {
      LOGGER.error(e);
    }
    catch (IOException e) {
      LOGGER.error("Unable to connect" + e.getCause());
    }

    return result;
  }
}
